<html>
<head><meta charset="utf-8"><title>Dropping `.await`- what else could or would change · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html">Dropping `.await`- what else could or would change</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="244780483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/244780483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#244780483">(Jul 03 2021 at 04:50)</a>:</h4>
<p>I have to admit: When I first read <span class="user-mention" data-user-id="224941">@Carl Lerche</span> 's idea about dropping <code>.await</code> I was mostly thinking "I don't care a lot - its fine either way". But today I was thinking a bit more about it, and wondered whether it's actually just the syntax that would change or whether there could be more behind it:</p>
<ul>
<li>If <code>.await</code> happens implicitely, there is no chance for users anymore to move <code>Futures</code> (or <code>Async</code>s?) around anymore before they are invoked. That ability in the current system made lifetimes incredibly complicated, since <code>Future</code>s  capture the lifetime of all their inputs, but might consume them at a different time (then the <code>Future</code> is polled). Assuming users can't move them anymore because the <code>.await</code>happens implicitely - could that mean lifetimes could be simplified and the exactly match the beavhior of synchronous functions?</li>
<li>One concern with todays <code>async</code> system that is less often talked about is large <code>Future</code> sizes. <code>Future</code>s which have been blowing the stack are now unheard of, and probalby even if the sizes are far smaller it might still hurt performance more than what we actually gain from <code>async</code> functions compared to normal stacks. My understanding is that parts of this size growth - which sometimes is exponential - is due to lazy composition of <code>Future</code>s - one first has to build a composite <code>Future</code> and return it before polling can start (but I think <span class="user-mention" data-user-id="116883">@tmandry</span> understands this topic far better). Assuming <code>Future</code>s are by default not movable since they are implicitely awaited - could this lead to smaller <code>Future</code> sizes due to being able to optimize compiler passes and maybe construct more things in-place?</li>
<li>For most basic functionality immediately awaiting a future is ok and dropping <code>.await</code> there too. But how would passing something async to a <code>spawn</code> function (either a scoped or global spawn) work? Carls example uses an async block there. Would those be restricted to that, or maybe even take async closures to get close to what a synchronous spawn look like (<code>scope.spawn(async || {} )</code>)? If yes, what is the type of what those functions are accepting? I don't think it should be <code>Async&lt;T&gt;</code>, since this like an already produced async operation. Maybe more along of an <code>impl AsyncFn</code> which when called produces an <code>Async&lt;T&gt;</code> - and there might be constraints on how you can use that one (e.g. you might not be allowed to defer polling too much to avoid the lifetime issues pointed out in point 1).</li>
</ul>



<a name="244855530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/244855530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#244855530">(Jul 04 2021 at 11:40)</a>:</h4>
<p>I dug some into this in the doc</p>



<a name="244855546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/244855546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#244855546">(Jul 04 2021 at 11:41)</a>:</h4>
<p>There isn't, I don't think, a change in expressiveness or anything else, but some things get simpler if you make <code>.await</code> the default</p>



<a name="244855553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/244855553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#244855553">(Jul 04 2021 at 11:41)</a>:</h4>
<p>Optimization potential is the most interesting to me</p>



<a name="244855558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/244855558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#244855558">(Jul 04 2021 at 11:41)</a>:</h4>
<p>But also the fact that the mental model between "sync" and "async" is identical-- e.g., in both cases, you make a "closure-like thing" to defer executing code immediately</p>



<a name="244855602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/244855602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#244855602">(Jul 04 2021 at 11:42)</a>:</h4>
<p>However, there are also some complications, depending on how we want to "expose" the idea that an async function doesn't immediately execute</p>



<a name="244855619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/244855619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#244855619">(Jul 04 2021 at 11:43)</a>:</h4>
<p>Ultimately it seems like a "detail" but not the most significant thing to me, though it has a huge impact on the daily writing of code and other things. I was surprised when writing some async code how much mental load I expended deciding whether I needed an await on some particular function or not. It's a constant question in the back of your mind, I find, and that's kind of a yellow flag for me.</p>



<a name="244861714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/244861714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ibraheem Ahmed <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#244861714">(Jul 04 2021 at 14:23)</a>:</h4>
<p>Just wondering, is this something that could actually change? It would be a pretty huge breaking change, no?</p>



<a name="245358518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245358518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245358518">(Jul 08 2021 at 19:16)</a>:</h4>
<p>We could certainly change it over an edition</p>



<a name="245358523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245358523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245358523">(Jul 08 2021 at 19:16)</a>:</h4>
<p>It would be a big migration though :)</p>



<a name="245381093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245381093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245381093">(Jul 08 2021 at 22:44)</a>:</h4>
<p>I've added some comments on the doc re this. tldr: I think it's a really really bad idea.</p>



<a name="245381180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245381180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245381180">(Jul 08 2021 at 22:45)</a>:</h4>
<p>(not sure what the right place to discuss is? can copypaste the comments here if wanted)</p>



<a name="245437272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245437272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245437272">(Jul 09 2021 at 12:41)</a>:</h4>
<p>Thanks! Will read. I'm currently in the process of moving things from the doc into a fork of wg-async-foundations, and I'm trying to include some of those comments either by adjusting the content or adding FAQs and things to discuss further</p>



<a name="245437298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245437298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245437298">(Jul 09 2021 at 12:41)</a>:</h4>
<p>I hope to get a PR up today, so we can move some of the discussion to that format, which is easier</p>



<a name="245437374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245437374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245437374">(Jul 09 2021 at 12:42)</a>:</h4>
<p>But I'd also be game to schedule a slot to go deeper, <span class="user-mention" data-user-id="348152">@Dario Nieuwenhuis</span>, especally about no-std considerations (I saw a number of comments from you in that direction)</p>



<a name="245464593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245464593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245464593">(Jul 09 2021 at 16:25)</a>:</h4>
<p>Would it make sense to have a preliminary design meeting discussion to go over some of the pros and cons of dropping <code>.await</code>? This seems like it informs enough things that it'd be worth starting that conversation early.</p>



<a name="245466392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245466392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245466392">(Jul 09 2021 at 16:39)</a>:</h4>
<p>I actually think it's a relatively minor detail</p>



<a name="245466400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245466400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245466400">(Jul 09 2021 at 16:39)</a>:</h4>
<p>But I do think that we need a number of design meetings</p>



<a name="245466509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245466509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245466509">(Jul 09 2021 at 16:40)</a>:</h4>
<p>The piece of this whole picture that <em>I personally</em> am most nervous about is <a href="https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/async_trait.html">introducing a second async trait</a></p>



<a name="245466545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245466545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245466545">(Jul 09 2021 at 16:40)</a>:</h4>
<p>I admit that when I first saw <span class="user-mention" data-user-id="204219">@Matthias247</span>'s PR I was pretty negative, but as I've dug more into this, I've become more and more convinced that it makes sense.</p>



<a name="245466591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245466591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245466591">(Jul 09 2021 at 16:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245466392">said</a>:</p>
<blockquote>
<p>I actually think it's a relatively minor detail</p>
</blockquote>
<p>Obviously a highly visible one :)</p>



<a name="245466799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245466799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245466799">(Jul 09 2021 at 16:42)</a>:</h4>
<p>Oh lol I didn't even include it in my PR yet, I should do that</p>



<a name="245477533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245477533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245477533">(Jul 09 2021 at 18:07)</a>:</h4>
<p>I feel it's kind of similar to the relationship between <code>FnMut</code> and <code>FnOnce</code>, imagine if the std definition is something like this:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">FutureOnce</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Output</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">poll_once</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">cx</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">Context</span><span class="o">&lt;'</span><span class="nb">_</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Output</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Future</span>: <span class="nc">FutureOnce</span><span class="w">  </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">poll</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span>: <span class="nc">Pin</span><span class="o">&lt;&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">Self</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">cx</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">Context</span><span class="o">&lt;'</span><span class="nb">_</span><span class="o">&gt;</span><span class="w"></span>
<span class="w">    </span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Poll</span><span class="o">&lt;</span><span class="bp">Self</span>::<span class="n">Output</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>The former one will serve well for non-interruptable futures, right?</p>



<a name="245478315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245478315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245478315">(Jul 09 2021 at 18:14)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I like the concept of the proposed new trait in theory. Am I interpreting correctly that we would allow both, so that it's possible to have a future that can be forgotten, but that's a property that you can choose?</p>



<a name="245478341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245478341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245478341">(Jul 09 2021 at 18:14)</a>:</h4>
<p>Because there are valid use cases for a future that never gets to finish.</p>



<a name="245478389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245478389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245478389">(Jul 09 2021 at 18:14)</a>:</h4>
<p>But I would also love to demarcate regions where I'm holding important data and don't want to drop it on the floor, as one of many examples.</p>



<a name="245478409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245478409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245478409">(Jul 09 2021 at 18:14)</a>:</h4>
<p>(or, better yet, not have to demarcate them)</p>



<a name="245478985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245478985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245478985">(Jul 09 2021 at 18:20)</a>:</h4>
<blockquote>
<p>I like the concept of the proposed new trait in theory. Am I interpreting correctly that we would allow both, so that it's possible to have a future that can be forgotten, but that's a property that you can choose?</p>
</blockquote>
<p>We can decide whether we want both! <a href="https://github.com/Matthias247/rfcs/pull/1">https://github.com/Matthias247/rfcs/pull/1</a> had described the way where <code>Future</code> is kept around to have a way of always cancellable <code>Future</code>s. However Niko also described it might be useful to have a broader migration to the new trait, which also makes sense to me.</p>
<p>I agree there are use-cases for the current system. For me the strongest use-case is something like a <code>select!</code> on multiple channels. Whichever receives an item first - we handle it. That requires the receive operations to be cancellable or pausable, which isn't that easy with the completion trait.</p>



<a name="245491419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245491419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245491419">(Jul 09 2021 at 20:08)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> I think we definitely want a way to express "this future can be canceled"</p>



<a name="245491469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245491469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245491469">(Jul 09 2021 at 20:09)</a>:</h4>
<p>I'm not 100% sure if using the old trait for that makes sense, but it's plausible</p>



<a name="245491513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245491513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245491513">(Jul 09 2021 at 20:09)</a>:</h4>
<p>the main argument against that I mentioned to <span class="user-mention" data-user-id="204219">@Matthias247</span> was basically that it uses <code>Pin</code> and that it might be the only place <code>Pin</code> is used; I'm not convinced <code>Pin</code> carries its weight there</p>



<a name="245491520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245491520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245491520">(Jul 09 2021 at 20:09)</a>:</h4>
<p>versus like a marker trait</p>



<a name="245491618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245491618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245491618">(Jul 09 2021 at 20:10)</a>:</h4>
<p>"what matthias said", basically :)</p>



<a name="245493369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493369">(Jul 09 2021 at 20:25)</a>:</h4>
<p>Well Pin there still allows for intrusive waiter lists that allow for MPMC channels, async semaphores and Mutexes, etc without any dynamic allocations. </p>
<p>While I think for Mutexes it can be worthwhile to think whether there i should only be non cancellable variants - I don’t see the same for channels yet. Unless we find another way to select over them (crossbeam can also do it in a synchronous world - so it should be doable)</p>



<a name="245493514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493514">(Jul 09 2021 at 20:27)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> So, the premise is that the new trait implies Pin but doesn't actually need to use Pin?</p>



<a name="245493567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493567">(Jul 09 2021 at 20:27)</a>:</h4>
<p>The new pin has an <code>unsafe</code> <code>poll</code> method, so we can make one of the conditions be that, once you start polling, you cannot move the pollee again</p>



<a name="245493587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493587">(Jul 09 2021 at 20:27)</a>:</h4>
<p>I don't think <code>Pin</code> buys you much at that stage</p>



<a name="245493646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493646">(Jul 09 2021 at 20:28)</a>:</h4>
<p>It seems like we have a lot of machinery around Pin to give people a way to express that.</p>



<a name="245493675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493675">(Jul 09 2021 at 20:28)</a>:</h4>
<p>I'm not <em>completely</em> sure that we want to just say "here's an unsafe function, be careful to not move the object afterward".</p>



<a name="245493721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493721">(Jul 09 2021 at 20:28)</a>:</h4>
<p>The thing is, nobody is calling that method but runtimes.</p>



<a name="245493746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493746">(Jul 09 2021 at 20:29)</a>:</h4>
<p>It's possible we could still use <code>Pin</code>, but I don't know that it carries its weight in that scenario.</p>



<a name="245493794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493794">(Jul 09 2021 at 20:29)</a>:</h4>
<p>People implementing futures also currently end up doing things with Pin sometimes, to express their data structures. How confident are we that nobody actually needs to do so?</p>



<a name="245493798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493798">(Jul 09 2021 at 20:29)</a>:</h4>
<p>It's a bit different today as there are a lot of <code>Poll</code> methods</p>



<a name="245493882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493882">(Jul 09 2021 at 20:30)</a>:</h4>
<p>For the record, I <em>love</em> the idea of eliminating both Pin and Poll as concerns for anyone not implementing a runtime.</p>



<a name="245493884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493884">(Jul 09 2021 at 20:30)</a>:</h4>
<p>I will say that I've yet to hear <em>anybody</em> say they understand <code>Pin</code></p>



<a name="245493897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493897">(Jul 09 2021 at 20:30)</a>:</h4>
<p>that is, anybody who is using async fn day to day</p>



<a name="245493918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493918">(Jul 09 2021 at 20:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245493884">said</a>:</p>
<blockquote>
<p>I will say that I've yet to hear <em>anybody</em> say they understand <code>Pin</code></p>
</blockquote>
<p>I feel like I understand it <em>better</em> after reading <a href="https://fasterthanli.me/articles/pin-and-suffering">https://fasterthanli.me/articles/pin-and-suffering</a> , but that doesn't make me happy about it. :)</p>



<a name="245493940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493940">(Jul 09 2021 at 20:31)</a>:</h4>
<p>I'm not sure that this argues against it <em>exactly</em></p>



<a name="245493980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493980">(Jul 09 2021 at 20:31)</a>:</h4>
<p>in other words, if <code>Pin</code> is making things hard because people would've been writing wrong unsafe code...</p>



<a name="245493991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245493991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245493991">(Jul 09 2021 at 20:31)</a>:</h4>
<p>Right.</p>



<a name="245494012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245494012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245494012">(Jul 09 2021 at 20:31)</a>:</h4>
<p>...anyway, I think the question of "When do you need to implement futures by hand" is a good one. I don't think there will be many cases.</p>



<a name="245494695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245494695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245494695">(Jul 09 2021 at 20:38)</a>:</h4>
<p>Bringing it back on topic, I'd be fine with dropping Pin if 1) we feel like we're still giving people enough tools to write the unsafe code for "don't move this" correctly (and ideally assisted by the type system), and 2) we don't need it for other things, like self-refs.</p>



<a name="245494742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245494742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245494742">(Jul 09 2021 at 20:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="204219">Matthias247</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245493369">said</a>:</p>
<blockquote>
<p>Well Pin there still allows for intrusive waiter lists that allow for MPMC channels, async semaphores and Mutexes, etc without any dynamic allocations. </p>
<p>While I think for Mutexes it can be worthwhile to think whether there i should only be non cancellable variants - I don’t see the same for channels yet. Unless we find another way to select over them (crossbeam can also do it in a synchronous world - so it should be doable)</p>
</blockquote>
<p>also things like <code>cxx</code> can express rust's inability to move std::string's by pinning any mutable access, overall its a great api even if the <code>Async trait</code> doesnt use it</p>



<a name="245494774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245494774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245494774">(Jul 09 2021 at 20:38)</a>:</h4>
<p>I kind of agree that if the method is already unsafe then Pin doesn’t buy terribly much. But if people want to keep it for the sake of expressing that extra requirement I’m also not opposed</p>



<a name="245494827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245494827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245494827">(Jul 09 2021 at 20:39)</a>:</h4>
<p>(did some thread juggling there)</p>



<a name="245494856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245494856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245494856">(Jul 09 2021 at 20:39)</a>:</h4>
<p><span class="user-mention" data-user-id="257428">@Gus Wynn</span> that's interesting! I didn't know about that.</p>



<a name="245494962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245494962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245494962">(Jul 09 2021 at 20:40)</a>:</h4>
<p>Pin is now also used heavily in the Rust for Linux kernel effort. Probably due to intrusive data structures</p>



<a name="245495069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245495069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245495069">(Jul 09 2021 at 20:41)</a>:</h4>
<p>Also interesting.</p>



<a name="245495495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245495495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245495495">(Jul 09 2021 at 20:44)</a>:</h4>
<p>We also use the drop guarantee of Pin in embedded to register/de-register interrupts</p>



<a name="245495526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245495526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245495526">(Jul 09 2021 at 20:45)</a>:</h4>
<p>And to access state in these interrupts</p>



<a name="245495580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245495580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245495580">(Jul 09 2021 at 20:45)</a>:</h4>
<p>Although I think Pin is a kinda bad, but it's what we have for that, I would love if it would be more baked into the language</p>



<a name="245495837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245495837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245495837">(Jul 09 2021 at 20:48)</a>:</h4>
<p>I also just had a case of needing to poll an async fn once before fully awaiting it, would that be possible somehow if .await gets removed ?</p>



<a name="245495919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245495919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245495919">(Jul 09 2021 at 20:49)</a>:</h4>
<p><span class="user-mention" data-user-id="204219">@Matthias247</span> In <a href="https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/async_trait.html">https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/async_trait.html</a> , what is <code>core::task::Ready</code> supposed to be? (That type doesn't exist today.)</p>



<a name="245496099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496099">(Jul 09 2021 at 20:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="267734">Thales Fragoso</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245495837">said</a>:</p>
<blockquote>
<p>I also just had a case of needing to poll an async fn once before fully awaiting it, would that be possible somehow if .await gets removed ?</p>
</blockquote>
<p>say more about this?</p>



<a name="245496132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496132">(Jul 09 2021 at 20:51)</a>:</h4>
<p>I guess the same as <code>Poll::Ready</code>? Just a new name to differentiate from old futures? <br>
It’s <span class="user-mention" data-user-id="116009">@nikomatsakis</span> invention, my RFC reused <code>Poll</code> 😀</p>



<a name="245496155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496155">(Jul 09 2021 at 20:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245495919">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="204219">Matthias247</span> In <a href="https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/async_trait.html">https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/async_trait.html</a> , what is <code>core::task::Ready</code> supposed to be? (That type doesn't exist today.)</p>
</blockquote>
<p>I meant to reuse Poll</p>



<a name="245496162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496162">(Jul 09 2021 at 20:51)</a>:</h4>
<p>I just misremembered the name :)</p>



<a name="245496165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496165">(Jul 09 2021 at 20:51)</a>:</h4>
<p>will fix</p>



<a name="245496267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496267">(Jul 09 2021 at 20:52)</a>:</h4>
<p><span class="user-mention" data-user-id="267734">@Thales Fragoso</span> can you elaborate on your use case? I'd say it'd be <em>possible</em> but highly discouraged :)</p>



<a name="245496505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496505">(Jul 09 2021 at 20:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> We have an async fn to setup a DMA transfer and await for it, it makes sense to setup and await in the same fn because when you enable the DMA you basically giving the buffer to it since it can start modifying it. </p>
<p>That works nicely, but some peripherals need some start condition to be done after the DMA is enabled, so the idea is to poll once for the setup, do the start condition and then await the DMA future</p>



<a name="245496668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496668">(Jul 09 2021 at 20:56)</a>:</h4>
<p>We could separate the setup and awaiting into two different fns, one normal and another async, but it would be kinda of error prone, because when you enable the DMA is when you really shouldn't be touching the buffer anymore, and it's the future that borrows it</p>



<a name="245496752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245496752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245496752">(Jul 09 2021 at 20:57)</a>:</h4>
<p>I'm curious whether a setup like</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">dma</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">Future</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cm">/* do the setup */</span><span class="w"></span>
<span class="w">    </span><span class="k">async</span><span class="w"> </span><span class="k">move</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>would work for you</p>



<a name="245497006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245497006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245497006">(Jul 09 2021 at 20:59)</a>:</h4>
<p>Hmm, that might be possible, yeah</p>



<a name="245497135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245497135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245497135">(Jul 09 2021 at 21:00)</a>:</h4>
<p>I would have to check the code, but I think that modification could be done</p>



<a name="245497274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245497274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245497274">(Jul 09 2021 at 21:00)</a>:</h4>
<p>I actually just hit this case today, so I haven't had the time to really go through it</p>



<a name="245497359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245497359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245497359">(Jul 09 2021 at 21:01)</a>:</h4>
<p>worth checking, seems simpler!</p>



<a name="245497400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245497400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245497400">(Jul 09 2021 at 21:01)</a>:</h4>
<p>Agreed, thanks</p>



<a name="245498902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245498902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245498902">(Jul 09 2021 at 21:07)</a>:</h4>
<p>I'd like to clarify how exactly "autoawait" would work. What would the <code>foo()</code> syntax mean in these cases?</p>
<ul>
<li>in async context, <code>foo</code> is an async fn -&gt; implicit await</li>
<li>in async context, <code>foo</code> is a normal fn -&gt; normal function call</li>
<li>in non-async context, <code>foo</code> is an async fn -&gt; ????</li>
<li>in non-async context, <code>foo</code> is a normal fn -&gt; normal function call</li>
</ul>



<a name="245499134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499134">(Jul 09 2021 at 21:08)</a>:</h4>
<p>Yeah, I'm not sure how that would work either :)</p>



<a name="245499166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499166">(Jul 09 2021 at 21:08)</a>:</h4>
<p>Certainly one way would be: you can't reference <code>foo</code> in a sync context</p>



<a name="245499177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499177">(Jul 09 2021 at 21:08)</a>:</h4>
<p>and</p>
<ul>
<li>How do you retrieve the Future for <code>foo()</code> as a plain value, in both async and non-async context?</li>
<li>If you have a Future value in a variable, how do you await it</li>
</ul>



<a name="245499381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499381">(Jul 09 2021 at 21:09)</a>:</h4>
<blockquote>
<p>you can't reference <code>foo</code> in a sync context</p>
</blockquote>
<p>how do you spawn an async task from a sync context then? you do that currently with <code>executor::spawn(foo())</code></p>



<a name="245499441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499441">(Jul 09 2021 at 21:09)</a>:</h4>
<p>probably <code>executor::spawn(async || foo())</code></p>



<a name="245499521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499521">(Jul 09 2021 at 21:10)</a>:</h4>
<p>I think the idea would be: if you want an <code>Async</code> value, you make an <code>async || </code> closure</p>



<a name="245499574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499574">(Jul 09 2021 at 21:10)</a>:</h4>
<p>async functions can only be invoked from inside an async context (and an async closure is such a context)</p>



<a name="245499635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499635">(Jul 09 2021 at 21:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245499441">said</a>:</p>
<blockquote>
<p>probably <code>executor::spawn(async || foo())</code></p>
</blockquote>
<p>obviously similar to <code>std::thread::spawn(move || foo())</code></p>



<a name="245499681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499681">(Jul 09 2021 at 21:11)</a>:</h4>
<p>but you can do <code>thread::spawn(foo)</code></p>



<a name="245499706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499706">(Jul 09 2021 at 21:11)</a>:</h4>
<p>sure</p>



<a name="245499725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499725">(Jul 09 2021 at 21:11)</a>:</h4>
<p>why do I need a closure for async spawn?</p>



<a name="245499796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499796">(Jul 09 2021 at 21:11)</a>:</h4>
<p>you actually maybe don't</p>



<a name="245499817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499817">(Jul 09 2021 at 21:11)</a>:</h4>
<p>I'm thinking</p>



<a name="245499920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499920">(Jul 09 2021 at 21:12)</a>:</h4>
<p>if we pursue the "there is no difference between an <code>Async</code> and a <code>AsyncFnOnce</code>"</p>



<a name="245499941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499941">(Jul 09 2021 at 21:12)</a>:</h4>
<p>then in a way, the call <em>is</em> the await</p>



<a name="245499989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245499989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245499989">(Jul 09 2021 at 21:12)</a>:</h4>
<p>also wouldn't it be <code>executor::spawn(async { foo() })</code>? <code>async{}</code> is a Future, <code>async || {}</code> is a <code>Fn() -&gt; impl Future</code> (?)</p>



<a name="245500005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500005">(Jul 09 2021 at 21:12)</a>:</h4>
<p>in that scenario, writing <code>let f = foo</code> gets you the <code>Async</code></p>



<a name="245500057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500057">(Jul 09 2021 at 21:12)</a>:</h4>
<p>in both a sync and an sync context</p>



<a name="245500082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500082">(Jul 09 2021 at 21:13)</a>:</h4>
<p>the only difference is that you can't <em>call</em> it in a sync context</p>



<a name="245500239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500239">(Jul 09 2021 at 21:13)</a>:</h4>
<p>(hmm, that doesnt make sense)</p>



<a name="245500245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500245">(Jul 09 2021 at 21:13)</a>:</h4>
<p>it has to capture the arguments :)</p>



<a name="245500322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500322">(Jul 09 2021 at 21:14)</a>:</h4>
<p><code>async fn foo</code> is a "factory of asyncs", not an "async" itself though, right?</p>



<a name="245500404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500404">(Jul 09 2021 at 21:14)</a>:</h4>
<p>right, that's what I just realized :)</p>



<a name="245500519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500519">(Jul 09 2021 at 21:15)</a>:</h4>
<p>so you need a way to "cause factorifying to happen without causing await to happen" to get the future to spawn that</p>



<a name="245500841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245500841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245500841">(Jul 09 2021 at 21:16)</a>:</h4>
<p>for that, I really can't think of a more elgant way than the current <code>foo()</code> vs <code>foo().await</code> to be honest...</p>



<a name="245501113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245501113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245501113">(Jul 09 2021 at 21:17)</a>:</h4>
<p>I somewhat agree :)</p>



<a name="245501287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245501287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245501287">(Jul 09 2021 at 21:18)</a>:</h4>
<p>That said, I do think that <code>AsyncDrop</code> inserting implicit awaits means that "look for await to find out where X happens" Is much less useful</p>



<a name="245501313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245501313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245501313">(Jul 09 2021 at 21:18)</a>:</h4>
<p>and I do think that when I write async code, having to insert await is annoying :)</p>



<a name="245502085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245502085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245502085">(Jul 09 2021 at 21:22)</a>:</h4>
<p>It does make logical sense to observe that people await a future more often than they pass it around without awaiting it. But at the same time, I think there's a certain "safety bias" here, where it feels a little more comfortable to have syntax for "do thing" rather than having syntax for "don't do thing".</p>



<a name="245502116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245502116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245502116">(Jul 09 2021 at 21:22)</a>:</h4>
<p>It's absolutely a tradeoff.</p>



<a name="245502169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245502169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245502169">(Jul 09 2021 at 21:22)</a>:</h4>
<p>(We could also consider other ways to address that tradeoff, such as entertaining shorter syntaxes for <code>.await</code>.)</p>



<a name="245502218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245502218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245502218">(Jul 09 2021 at 21:22)</a>:</h4>
<p>I don't think the length of the keyword is a problem</p>



<a name="245502329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245502329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245502329">(Jul 09 2021 at 21:23)</a>:</h4>
<p>Seems worth considering, at least. We went from <code>try!</code> to <code>?</code> and that made error handling <em>much</em> better.</p>



<a name="245502366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245502366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245502366">(Jul 09 2021 at 21:23)</a>:</h4>
<p>In async code, <code>.await</code> seems as prevalent as <code>?</code>, but it's much more verbose.</p>



<a name="245502621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245502621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245502621">(Jul 09 2021 at 21:24)</a>:</h4>
<p>Another potential option would be the idea of an <code>await {}</code> block, which uses auto-await syntax for all async functions within. That might be more comfortable than forcing auto-await <em>everywhere</em>.</p>



<a name="245502705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245502705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245502705">(Jul 09 2021 at 21:25)</a>:</h4>
<p>I think in general terms I'm suggesting that if we consider that tradeoff important, we might want to entertain other possible solutions that touch on the same tradeoff.</p>



<a name="245504150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245504150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245504150">(Jul 09 2021 at 21:32)</a>:</h4>
<p>"optional autoawait syntax" would be even worse imo. <code>foo()</code> would mean radically different things based on context</p>



<a name="245504399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245504399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245504399">(Jul 09 2021 at 21:33)</a>:</h4>
<p>I already really don't like that <code>my_async_fn()</code> and <code>my_sync_fn()</code> mean different things, but having <code>my_async_fn()</code> mean different thigns based on context is even worse</p>



<a name="245504716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245504716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245504716">(Jul 09 2021 at 21:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245502329">said</a>:</p>
<blockquote>
<p>Seems worth considering, at least. We went from <code>try!</code> to <code>?</code> and that made error handling <em>much</em> better.</p>
</blockquote>
<p>the big shift here, imo, was moving to postfix form.</p>



<a name="245504797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245504797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245504797">(Jul 09 2021 at 21:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="348152">Dario Nieuwenhuis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245504399">said</a>:</p>
<blockquote>
<p>I already really don't like that <code>my_async_fn()</code> and <code>my_sync_fn()</code> mean different things</p>
</blockquote>
<p>this is, of course, what I am driving at :)</p>



<a name="245504920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245504920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245504920">(Jul 09 2021 at 21:36)</a>:</h4>
<p>still, I definitely see yor point that it's hard to see how removing <code>await</code> would <strong>actually work</strong> when you drill into the details :)</p>



<a name="245504943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245504943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245504943">(Jul 09 2021 at 21:36)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> was making a similar point to me as well</p>



<a name="245505337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245505337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245505337">(Jul 09 2021 at 21:38)</a>:</h4>
<p>well even if we figured out the details, I disagree with the <em>idea</em> too :S</p>



<a name="245505839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245505839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245505839">(Jul 09 2021 at 21:41)</a>:</h4>
<p>Rust is a very explicit language. The compiler won't use vtables unless you write <code>dyn</code>. The compiler won't do allocations unless you write <code>Box::new</code>, etc etc</p>



<a name="245505881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245505881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245505881">(Jul 09 2021 at 21:41)</a>:</h4>
<p>implicit await would be a major departure from this</p>



<a name="245506322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506322">(Jul 09 2021 at 21:44)</a>:</h4>
<p>Do you feel the same way about <code>AsyncDrop</code>?</p>



<a name="245506496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506496">(Jul 09 2021 at 21:45)</a>:</h4>
<p><em>mayyybe</em> a bit too, yes, but much less strongly</p>



<a name="245506558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506558">(Jul 09 2021 at 21:45)</a>:</h4>
<p>what makes it different?</p>



<a name="245506560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506560">(Jul 09 2021 at 21:45)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">dma</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">Future</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cm">/* do the setup */</span><span class="w"></span>
<span class="w">    </span><span class="k">async</span><span class="w"> </span><span class="k">move</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> how would a be able to write if we remove .await ?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">fut</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dma</span><span class="p">();</span><span class="w"></span>
<span class="n">send_start</span><span class="p">();</span><span class="w"></span>
<span class="n">fut</span><span class="p">.</span><span class="k">await</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="245506702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506702">(Jul 09 2021 at 21:46)</a>:</h4>
<p>Drop is already "magic implicit function calls"<br>
AsyncDrop would be "magic implicit async function calls"</p>



<a name="245506798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506798">(Jul 09 2021 at 21:46)</a>:</h4>
<p><span class="user-mention" data-user-id="267734">@Thales Fragoso</span> presumably <em>that</em> would be </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">dma</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">AsyncFnOnce</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">do_setup</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="k">async</span><span class="w"> </span><span class="k">move</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>and then</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">closure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">dma</span><span class="p">();</span><span class="w"></span>
<span class="n">send_start</span><span class="p">();</span><span class="w"></span>
<span class="n">closure</span><span class="p">();</span><span class="w"></span>
</code></pre></div>



<a name="245506872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506872">(Jul 09 2021 at 21:47)</a>:</h4>
<p>...or something like that :)</p>



<a name="245506891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506891">(Jul 09 2021 at 21:47)</a>:</h4>
<p>Got it</p>



<a name="245506915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506915">(Jul 09 2021 at 21:47)</a>:</h4>
<p>and Drop/AsyncDrop for the most part is quite "predictable", it just does cleanup</p>



<a name="245506949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245506949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245506949">(Jul 09 2021 at 21:47)</a>:</h4>
<p>anyway, I don't know :) I want to go off and play with it now that <span class="user-mention" data-user-id="348152">@Dario Nieuwenhuis</span> poked a bunch of holes in my idea of what it would be like</p>



<a name="245507011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507011">(Jul 09 2021 at 21:48)</a>:</h4>
<p>but (as I said at the top of this thread...) to me, the question of <code>.await</code> or not is relatively minor</p>



<a name="245507088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507088">(Jul 09 2021 at 21:48)</a>:</h4>
<p>I'm much more keen on scopes and other things as a solution to a bunch of problems</p>



<a name="245507110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507110">(Jul 09 2021 at 21:48)</a>:</h4>
<p>I would like to explore alternatives to AsyncDrop, though</p>



<a name="245507151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507151">(Jul 09 2021 at 21:48)</a>:</h4>
<p>I'd be curious to talk it out</p>



<a name="245507207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507207">(Jul 09 2021 at 21:48)</a>:</h4>
<p>I thought about it a fair bit and came to the conclusion that you really <em>do</em> want it to work implicitly, but it'd be interesting to find another option</p>



<a name="245507238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507238">(Jul 09 2021 at 21:49)</a>:</h4>
<p>I guess you could imagine <code>{ ... }.await</code> or something :)</p>



<a name="245507306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507306">(Jul 09 2021 at 21:49)</a>:</h4>
<p>but it's really stuff like <code>?</code> operator and <code>break</code> that does it for me</p>



<a name="245507363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507363">(Jul 09 2021 at 21:49)</a>:</h4>
<p>for example the <code>?Drop</code> idea could be used to forbid sync-dropping something<br>
for example on a file i/o lib,  this could be used to force the user to call an async <code>.close()</code></p>



<a name="245507401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507401">(Jul 09 2021 at 21:50)</a>:</h4>
<p>Yes, I went down that road.</p>



<a name="245507419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507419">(Jul 09 2021 at 21:50)</a>:</h4>
<p>but that's not implicit at all, no</p>



<a name="245507460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507460">(Jul 09 2021 at 21:50)</a>:</h4>
<p><code>?Drop</code> is a pretty major chagne to the language though</p>



<a name="245507480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507480">(Jul 09 2021 at 21:50)</a>:</h4>
<p>I could imagine that becoming annoying</p>



<a name="245507495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507495">(Jul 09 2021 at 21:50)</a>:</h4>
<p>plus, I think if you work it out-- that</p>



<a name="245507575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507575">(Jul 09 2021 at 21:50)</a>:</h4>
<p>well speaking of major changes for the language...<br>
I would like to lobby for <code>?Leak</code> too <span aria-label="rofl" class="emoji emoji-1f923" role="img" title="rofl">:rofl:</span></p>



<a name="245507587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507587">(Jul 09 2021 at 21:50)</a>:</h4>
<p>(<code>?Drop</code> does have stuff to recommend it; it might be a good idea)</p>



<a name="245507660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507660">(Jul 09 2021 at 21:51)</a>:</h4>
<p>I <em>think</em> it's possible to remove the need for the "Future 2.0" trait (Async) if we have <code>?Drop</code> and <code>?Leak</code></p>



<a name="245507712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507712">(Jul 09 2021 at 21:51)</a>:</h4>
<p>Plausibly</p>



<a name="245507744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507744">(Jul 09 2021 at 21:51)</a>:</h4>
<p>But those are <em>much</em> more disruptive changes :)</p>



<a name="245507772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507772">(Jul 09 2021 at 21:51)</a>:</h4>
<p>And unlike a Futures 2.0, they don't go away in time</p>



<a name="245507856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507856">(Jul 09 2021 at 21:52)</a>:</h4>
<p><code>?Drop</code> would be much, much cleaner IMO. Having a second trait feels like an ugly hack/workaround of limitations of the Rust type system</p>



<a name="245507871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507871">(Jul 09 2021 at 21:52)</a>:</h4>
<blockquote>
<p>in non-async context, foo is an async fn -&gt; ????</p>
</blockquote>
<p>I would have expected it is a compilation error just like it would be in Kotlin or C++</p>



<a name="245507987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245507987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245507987">(Jul 09 2021 at 21:53)</a>:</h4>
<p><code>?Drop</code> and <code>?Leak</code> address the root cause of the issue</p>



<a name="245508086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245508086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245508086">(Jul 09 2021 at 21:53)</a>:</h4>
<p>while <code>Async</code> workarounds it with unsafe asking the user to "hey please don't drop me OK?"</p>



<a name="245508206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245508206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245508206">(Jul 09 2021 at 21:54)</a>:</h4>
<blockquote>
<p>but you can do thread::spawn(foo)</p>
</blockquote>
<p>But <code>foo</code> is the name of the function, not an invocation. If you do <code>spawn(foo())</code> it will also do the immediate invocation.<br>
Imho it would be perfectly resembling the synchronous world if one had to do <code>spawn(async || async_foo())</code> or <code>spawn(async_foo)</code>.</p>



<a name="245508378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245508378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245508378">(Jul 09 2021 at 21:55)</a>:</h4>
<p>no</p>
<p>in sync a "runnable unit" is a closure<br>
in async a "runnable unit" is a future</p>
<p>an async closure is a "factory of futures"</p>



<a name="245508416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245508416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245508416">(Jul 09 2021 at 21:55)</a>:</h4>
<p>async spawn should take a future, not an async closure</p>



<a name="245510457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245510457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245510457">(Jul 09 2021 at 22:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="348152">Dario Nieuwenhuis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245507660">said</a>:</p>
<blockquote>
<p>I <em>think</em> it's possible to remove the need for the "Future 2.0" trait (Async) if we have <code>?Drop</code> and <code>?Leak</code></p>
</blockquote>
<p>Can I get a bit more context on the implication of <code>?Drop</code> and <code>?Leak</code>? Is the idea here to have types that you're not allowed to implicitly drop, and <em>must</em> explicitly drop?</p>



<a name="245510693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245510693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alice Ryhl <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245510693">(Jul 09 2021 at 22:08)</a>:</h4>
<p>I mean, I've wanted types that you _have_ to explicitly consume somehow for a long time, just because it is helpful for writing hard-to-misuse APIs.</p>



<a name="245510719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245510719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245510719">(Jul 09 2021 at 22:09)</a>:</h4>
<p>yeah!</p>



<a name="245510812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245510812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245510812">(Jul 09 2021 at 22:09)</a>:</h4>
<p>I imagine it would be something like this (completely invented syntax)</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="o">..</span><span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="o">!</span><span class="nb">Drop</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Foo</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">bar</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Foo</span>::<span class="n">new</span><span class="p">();</span><span class="w"></span>
<span class="w">  </span><span class="c1">// compile error: you may not drop an instance of Foo</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="245510983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245510983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245510983">(Jul 09 2021 at 22:10)</a>:</h4>
<p>then <code>Foo</code> could define a <code>fn close(self)</code> that you <em>have</em> to call to get rid of it</p>



<a name="245511014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245511014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245511014">(Jul 09 2021 at 22:10)</a>:</h4>
<p>or even <code>async fn close(self)</code> to enforce closing is async</p>



<a name="245511126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245511126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alice Ryhl <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245511126">(Jul 09 2021 at 22:11)</a>:</h4>
<p>I mean, you run in to the issue that you can't use <code>?</code> in any function with such a type in scope, so it's not as clear cut.</p>



<a name="245511208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245511208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245511208">(Jul 09 2021 at 22:12)</a>:</h4>
<p>with this, you can use the current <code>Future</code> trait for non-cancellable futures, no need for a new trait</p>



<a name="245511235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245511235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245511235">(Jul 09 2021 at 22:12)</a>:</h4>
<p>oh taht's true, hmm...</p>



<a name="245514724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245514724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245514724">(Jul 09 2021 at 22:53)</a>:</h4>
<p>Also please consider that some of those things are about intent and usability, instead of just combining low-levels things. Of course one could offer things like "use a generator instead of an async fn, combine that with traits like <code>?Drop</code> and <code>?Leak</code>, and sprinkle a bit of <code>Pin</code> in between ".</p>
<p>However which "casual developer" can really keep up with all of those terms? <code>async fn</code>  is imho intended to be an easy way for the majority of developers to write code which multiplexes multiple tasks on a thread . This is a super common requirement,  and in my team we have like 50 developers writing code that way. Out of that, at least 45 likely don't know that what <code>?Trait</code>, other kinds of higher level trait bounds  or <code>Pin</code> is.</p>



<a name="245514992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245514992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245514992">(Jul 09 2021 at 22:57)</a>:</h4>
<p>I do undestand that's the rationale behind these proposals</p>



<a name="245515352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245515352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245515352">(Jul 09 2021 at 23:02)</a>:</h4>
<p>however:</p>
<ol>
<li>Rust is an inherently low level language. Developers have to deal with complexity, such as lifetimes, subtle distinctions like Arc vs Rc, Send/Sync, etc. Rust has always been about giving the developer tools to manage that complexity safely and productively <em>but without hiding it</em>. Rust will not use vtables unless you write <code>dyn</code>. Rust will not do allocations unless you write <code>Box::new</code>. Rust will not do integer casts unless you write <code>as</code>. I fail to see a justification of why should async Rust be different.</li>
</ol>



<a name="245515484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245515484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245515484">(Jul 09 2021 at 23:04)</a>:</h4>
<ol start="2">
<li>JS developers have been writing <code>await</code> at every async call just fine for years, and JS is arguably one of the most removed-from-low-level-stuff languages. And the JS developer population is overwhelmingly junior devs.</li>
</ol>



<a name="245516012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516012">(Jul 09 2021 at 23:13)</a>:</h4>
<p>I'm with <span class="user-mention" data-user-id="116009">@nikomatsakis</span> on that one. It depends on what you gain from having access to more functionality. Without <code>dyn Trait</code>, you can avoid the cost for dynamic dispatch. What is the reason for having an explicit future on the stack that is only valid if you very carefully handle it? And even if you require to have that mechanism - the approach would not take it away - it just requires a different syntax.  </p>
<p>And think about it - you don't see raw stack frames in rust either, or don't see raw pointers by default. You don't really know whether the compiler passes something by copy or value if both approaches are valid. There's already lots of abstraction for use-cases where there are sane defaults for most users.</p>



<a name="245516077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516077">(Jul 09 2021 at 23:15)</a>:</h4>
<ol start="3">
<li>I'm fairly confident that it's possible to wire up some lowlevel machinery like <code>AsyncDrop</code> or <code>?Drop</code> to get the high-level properties we want, so that it Just Works for high-level code without high-level users having to learn these in depth.</li>
</ol>



<a name="245516098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516098">(Jul 09 2021 at 23:15)</a>:</h4>
<p>I would argue the cost of an "await" is higher than the cost of dynamic dispatch / box</p>



<a name="245516220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516220">(Jul 09 2021 at 23:17)</a>:</h4>
<p>and it's not just the cost of the await itself. You often want to control where a big buffer goes. Currently it's super easy: are you holding the big buffer across an await? it goes on the future, otherwise it goes in the stack.</p>



<a name="245516247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516247">(Jul 09 2021 at 23:17)</a>:</h4>
<p>so with a quick look you can tell whether an <code>async fn</code> will have a bloated future or not, and quickly fix it</p>



<a name="245516294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516294">(Jul 09 2021 at 23:18)</a>:</h4>
<p>if you hide awaits, that's no longer possible</p>



<a name="245516314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516314">(Jul 09 2021 at 23:18)</a>:</h4>
<p>you have to check the docs of each and every single "function call-looking" <code>foo()</code> to see if it's a function call or an await</p>



<a name="245516337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516337">(Jul 09 2021 at 23:18)</a>:</h4>
<p>This makes async HARDER to use in applications where you care about memory usage, not easier.</p>



<a name="245516498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516498">(Jul 09 2021 at 23:21)</a>:</h4>
<p><code>+ 1</code> to know if a buffer goes in a future or the stack. I got bit by this recently</p>



<a name="245516733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516733">(Jul 09 2021 at 23:24)</a>:</h4>
<blockquote>
<p>it goes on the future, otherwise it goes in the stack.</p>
</blockquote>
<p>I think this is a reasonable argument  for it - which is alongside the <code>Send/Sync</code> requirement ones.<br>
It had been mentioned that those things could be highlighted by IDEs. But since not everyone uses an IDE, and for example there are typically none for code-views, there are also points against that</p>



<a name="245516788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516788">(Jul 09 2021 at 23:25)</a>:</h4>
<p>I find the "your IDE will highlight that" argument pretty weak, yes</p>



<a name="245516886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516886">(Jul 09 2021 at 23:27)</a>:</h4>
<p>Another thing: <code>await</code> makes the points at which your future can get canceled (dropped) really visible.</p>



<a name="245516904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245516904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245516904">(Jul 09 2021 at 23:27)</a>:</h4>
<p>This has been priceless in ensuring correctness in Embassy's async HALs (hardware abstraction layers)</p>



<a name="245517073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517073">(Jul 09 2021 at 23:30)</a>:</h4>
<p>for example, a "send bytes" async fn would do:</p>
<ul>
<li>Set up DMA to send the bytes, start it (all sync register writes)</li>
<li>Await DMA completion</li>
<li>Cleanup state (all sync register writes again)</li>
</ul>
<p>With a very quick glance at the code, I can know there's only 2 possible paths through that code:</p>
<ul>
<li>Setup, await, cleanup -&gt; all great</li>
<li>Setup, await, cancel -&gt; I setup a drop handler to stop DMA on cancel to ensure correctness</li>
</ul>
<p>And that's it! I have the guarantee that these two paths are correct, everything's great.</p>



<a name="245517245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517245">(Jul 09 2021 at 23:33)</a>:</h4>
<p>However, with "autoawait":</p>
<ol>
<li>It's now no longer possible to ensure there's just these two possible code paths through visual inspection</li>
<li>Someone else might change a sync fn called in cleanup to async. This would introduce a third code path through this function! And the code would compile as-is, so this would go unnoticed and this function will likely behave incorrectly if the future is canceled in this new 3rd code path.</li>
</ol>



<a name="245517274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517274">(Jul 09 2021 at 23:33)</a>:</h4>
<p>Regular function calls and awaits having different syntax is a <em>feature</em></p>



<a name="245517280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517280">(Jul 09 2021 at 23:34)</a>:</h4>
<p>You are missing that we are talking about a new non-cancellable trait</p>



<a name="245517321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517321">(Jul 09 2021 at 23:34)</a>:</h4>
<p>I <em>want</em> my futures to be cancelable</p>



<a name="245517338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517338">(Jul 09 2021 at 23:34)</a>:</h4>
<p>The problem is not "I want to prevent cancelation", it's "I want to ensure correctness when cancelation happens"</p>



<a name="245517358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517358">(Jul 09 2021 at 23:35)</a>:</h4>
<p>Implicit awaits make ensuring correctness incredibly hard</p>



<a name="245517791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517791">(Jul 09 2021 at 23:42)</a>:</h4>
<p>Well there have been cases where there is really no safe way to correctly handle cancellation.  That is the main motivation for another trait. Please try to catch up on those before dismissing it.</p>
<p>Dropping <code>.await</code> is mostly an additional idea, around which I personally have no strong opinion. I think it will likely work fine either way,  with some minor adjustments here and there to accomodate some use-cases</p>



<a name="245517845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517845">(Jul 09 2021 at 23:43)</a>:</h4>
<p>I'm not dismissing the need for some form of async cancel / async drop, and I have caught up with all discussions on that.</p>



<a name="245517908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245517908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245517908">(Jul 09 2021 at 23:44)</a>:</h4>
<p>All of the above are arguments against autoawait</p>



<a name="245622921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245622921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245622921">(Jul 11 2021 at 19:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="348152">Dario Nieuwenhuis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245517908">said</a>:</p>
<blockquote>
<p>All of the above are arguments against autoawait</p>
</blockquote>
<p>TBH they also read as arguments against panic and sync Drop! Giving sync and async calls different syntax is only a feature if you also assume a bunch of other differences between the two are fundamental (e.g. lack of async Drop, weird interactions between Send/Sync and threads vs tasks)</p>
<p>But the whole overarching goal here is to make the two more similar, because the differences keep turning out to be footguns and/or roadblocks. And of course this has to be predicated on preserving some important things about async, but determining which aspects of async are critical and which are "just" workarounds is the hard part.</p>
<p>IMO it helps to consider the critical aspects of async to be purely on the "generated code" side- sync code uses large dynamically allocated stacks with an ambient cross-language preemptive kernel scheduler; async code uses small (mostly-)fixed-size stacks with a language-integrated cooperative user-space scheduler. Everything else flows from this, or else it is probably equally important to solve in sync code!</p>
<p>So back to the start of this message- if your problem with autoawait is that it makes it harder to pick out the full set of control flow paths... then why is this not also a problem with sync code which can also panic (the sync version of cancellation) at any function call? Either sync code makes that potential explosion fine somehow (e.g. Drop can block, thus async Drop would provide identical benefits to autoawait) or else the sync code has the same problem (and thus we should approach the problem more generally rather than doubling down on the status quo for async only).</p>



<a name="245623414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245623414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ibraheem Ahmed <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245623414">(Jul 11 2021 at 19:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245502329">said</a>:</p>
<blockquote>
<p>Seems worth considering, at least. We went from <code>try!</code> to <code>?</code> and that made error handling <em>much</em> better.</p>
</blockquote>
<p><code>try!</code> to <code>?</code> means we went from <code>try!(try!(try!(foo).bar()).baz))</code> to <code>foo?.bar()?.baz()?</code>. I think the big difference it the postfix syntax, and that already happened with <code>await! -&gt; .await</code>. I don't thing shortening the keyword will really help.</p>



<a name="245629616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245629616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245629616">(Jul 11 2021 at 22:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="117495">rpjohnst</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245622921">said</a>:</p>
<blockquote>
<p>if your problem with autoawait is that it makes it harder to pick out the full set of control flow paths... then why is this not also a problem with sync code which can also panic (the sync version of cancellation) at any function call? </p>
</blockquote>
<p>IMO panic is not the sync version of cancelation. In sync code you cancel stuff by setting some flag, or by using deadlines/timeouts/close on sockets, and bubble up the returned errors in <code>Result</code>s.</p>
<p>And indeed, using panics for error handling or cancelation is a very bad practice and makes ensuring correctness really hard. It should be only used for unrecoverable, fatal errors.</p>
<p>In embedded, <code>panic</code> usually doesn't even unwind, it might do some emergency cleanup to bring the system to a safe state (like stopping motors) then reboot the entire microcontroller. A panic is not a "sync cancelation", it's a "the universe ends and time stops" thing, there's no "after" to worry about.</p>
<p>However, in async canceling a future by dropping it is the intended, officially blessed way of doing it. Not a bad practice.</p>



<a name="245629870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245629870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245629870">(Jul 11 2021 at 22:12)</a>:</h4>
<p>This is not a big problem in sync code because most programs don't even attempt to recover from panics, or when they do they do it at a very coarse granularity (per HTTP request in a server, for example) which causes all state to be thrown away.</p>



<a name="245629886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245629886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245629886">(Jul 11 2021 at 22:13)</a>:</h4>
<p>Panic "cancelation" can only cause issues if a thread panics <em>while mutating global state</em> in a program that recovers panics such as an HTTP server. And even then, such global state is probably behind a Mutex which gets poisoned in this case.</p>



<a name="245630071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245630071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245630071">(Jul 11 2021 at 22:17)</a>:</h4>
<p>tldr sync panic is for fatal errors and not intended to be recovered from, while async cancel is normal routine</p>



<a name="245714880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245714880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245714880">(Jul 12 2021 at 16:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="348152">Dario Nieuwenhuis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245629616">said</a>:</p>
<blockquote>
<p>IMO panic is not the sync version of cancelation. In sync code you cancel stuff by setting some flag, or by using deadlines/timeouts/close on sockets, and bubble up the returned errors in <code>Result</code>s.</p>
</blockquote>
<p>it's an operational comparison, not a purpose comparison. panic is functionally near-identical to future cancellation- destructors on the stack are run and the thread never continues (speaking in terms of panic=unwind here obviously!)</p>
<p>so in that sense what you're saying simply suggests that future cancellation should only be used for unrecoverable errors, rather than actual semantic cancellation! and that's exactly the sort of idea coming out of "make sync/async more similar"/"support async drop"/etc.</p>



<a name="245715307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245715307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245715307">(Jul 12 2021 at 16:57)</a>:</h4>
<p>and thus, if the consequences of panic and future cancellation are such that it only makes sense to use them for unrecoverable errors, then the question becomes: why are we trying to reason about future cancellation control flow paths, instead of just doing cancellation via bubbling Result and letting Drop handle the cleanup? (probably, again, because we don't have async Drop!)</p>



<a name="245715784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245715784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245715784">(Jul 12 2021 at 17:00)</a>:</h4>
<p>or to flip things around in the other direction- we have .await markers so it's (apparently) feasible to reason about future cancellation. why not add panic-point markers so it becomes feasible to reason about panic cancellation?</p>



<a name="245739639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245739639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kestrer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245739639">(Jul 12 2021 at 19:58)</a>:</h4>
<blockquote>
<p>why not add panic-point markers so it becomes feasible to reason about panic cancellation?</p>
</blockquote>
<p>Because you write code assuming panics don't happen. I believe that all expected code paths (that is: continuation and cancellation) should be marked with a symbol (<code>.await</code>), where all unexpected code paths (panic) shouldn't be.</p>
<p>Supporting cancellation by default is a good thing, because it makes it much easier to write async code. One of the most common questions I see about sync code is "how do I cancel a thread", and solutions are always complex. But with async and explicit <code>.await</code>, we get the best of both worlds: Easy task cancellation without it being a footgun (since cancellation points are obvious).</p>
<p>Note that with Dario's async model, it is possible to write a combinator <code>.must_complete()</code> which would enforce that a certain future is never cancelled, so it is entirely possible to achieve the same semantics as proposed by this one. I suspect this combinator will be very useful.</p>



<a name="245743336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245743336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245743336">(Jul 12 2021 at 20:26)</a>:</h4>
<p>Note that with completion async fn cancellation points are the regular return values of function calls, and you can detect them also be looking at whether a function returns <code>Result&lt;T, AnErrorEnumerationWhichIncludesAPotentialCancellationError&gt;</code></p>



<a name="245749110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245749110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kestrer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245749110">(Jul 12 2021 at 21:04)</a>:</h4>
<p>I don't really like that, because it forces all operations to be fallible. Something like <code>sleep</code> having to return a <code>Result</code> would just be a pain. <code>?</code> exists but you'd have to add a Cancelled variant to all your error enums and that's really not ideal. I think combining implicit cancellation with <code>AsyncDrop</code> for async cleanup is a slightly nicer solution.</p>



<a name="245752644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245752644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245752644">(Jul 12 2021 at 21:28)</a>:</h4>
<p>It totally makes sense for <code>sleep</code> to return an error on cancellation, because it didn't sleep as long as you wanted.</p>



<a name="245754734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245754734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245754734">(Jul 12 2021 at 21:48)</a>:</h4>
<p>Cancellation, in the <code>sleep</code> scenario, sounds more like someone mutated a value (the sleep future) you owned; if there's something to allow such mutation, shouldn't the <code>Output</code> of that future include whether or not someone else touched it? I feel like cancellation isn't a "failure" circumstance <em>except</em> if it means "cancelled out from under you, in an operation you expected not to fail".</p>
<p>Cancellation by the owner is the only way that should ever occur, otherwise- and if something causes a failure to perform a sleep successfully because of a dependency not pulling through, wouldn't that explicitly be something other than a cancellation?</p>



<a name="245781240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245781240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kestrer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245781240">(Jul 13 2021 at 05:35)</a>:</h4>
<p>Functions that would otherwise be infallible returning cancellation errors would result in <code>.unwrap()</code>s being necessary in contexts where you don't expect it to be cancelled, for example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">future</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">async</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">sleep</span><span class="p">(</span><span class="n">duration</span><span class="p">).</span><span class="k">await</span><span class="p">.</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">do_work</span><span class="p">().</span><span class="k">await</span><span class="p">.</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">sleep</span><span class="p">(</span><span class="n">other_duration</span><span class="p">).</span><span class="k">await</span><span class="p">.</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">other_thing</span><span class="p">().</span><span class="k">await</span><span class="p">.</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="p">.</span><span class="n">must_complete</span><span class="p">();</span><span class="w"></span>
</code></pre></div>



<a name="245854585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245854585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245854585">(Jul 13 2021 at 16:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="360486">Kestrer</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245739639">said</a>:</p>
<blockquote>
<p>Supporting cancellation by default is a good thing, because it makes it much easier to write async code.</p>
</blockquote>
<p>But this is not borne out in practice, that's the whole point. "Oops this got cancelled and broke something" is one of the main footguns this wg is looking at, no? In fact, in this thread Dario made the argument that .await is necessary <em>because</em> cancellation is available by default, but at the same time cancellation keeps catching people by surprise anyway. So arguably, ".await helps reason about control flow" is not really helpful on its own- it only makes sense in the context of this particular kind of (error-prone) cancellation!</p>
<p>I'm not trying to "take a side" on explicit vs implicit cancel/panic points here- I'm trying to point out that the differences between the two are perhaps more accidental than fundamental or intentional, and in particular the current division between them is not the only possible or reasonable one. For example if cancellation were less error-prone somehow (e.g. async Drop, to match the sync approach to cleanup), then would explicit .await really be such an important tool anymore? Importantly, the goal is not to remove .await per se, but to improve cancellation.</p>



<a name="245864711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245864711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kestrer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245864711">(Jul 13 2021 at 18:09)</a>:</h4>
<blockquote>
<p>But this is not borne out in practice, that's the whole point.</p>
</blockquote>
<p>The example I have seen of cancellation being a footgun used <code>select!</code> in a loop, and I would consider that to be the real footgun here. That pattern should be eliminated, and replaced with the much more obvious and less footgunny approach of simply <code>select</code>ing two futures, where each future contains its own loop. Cancellation itself is not a problem; if made explicit by <code>select</code>ing two futures once or calling <code>.abort()</code>, there is no surprise that a future will stop in the middle of executing. So I wouldn't describe this method of cancellation as error-prone; just one common usage of it.</p>
<p>I'm not really sure on how async drop would affect the error-proneness of implicit cancellation points, but Dario's above arguments would still apply.</p>



<a name="245879407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245879407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245879407">(Jul 13 2021 at 20:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="117495">rpjohnst</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change/near/245622921">said</a>:</p>
<blockquote>
<p>IMO it helps to consider the critical aspects of async to be purely on the "generated code" side- sync code uses large dynamically allocated stacks with an ambient cross-language preemptive kernel scheduler; async code uses small (mostly-)fixed-size stacks with a language-integrated cooperative user-space scheduler. Everything else flows from this, or else it is probably equally important to solve in sync code!</p>
</blockquote>
<p>I agree with this, <span class="user-mention" data-user-id="117495">@rpjohnst</span> </p>
<blockquote>
<p>So back to the start of this message- if your problem with autoawait is that it makes it harder to pick out the full set of control flow paths... then why is this not also a problem with sync code which can also panic (the sync version of cancellation) at any function call? Either sync code makes that potential explosion fine somehow (e.g. Drop can block, thus async Drop would provide identical benefits to autoawait) or else the sync code has the same problem (and thus we should approach the problem more generally rather than doubling down on the status quo for async only).</p>
</blockquote>
<p>Initially I was making this same argument -- but the main difference here, imo, is <code>select</code>. This is why I wrote the story <a href="https://rust-lang.github.io/wg-async-foundations/vision/status_quo/barbara_gets_burned_by_select.html">Barbara gets burned by select</a>. In short, cancellation is (idiomatically) used far more often than <code>panic!</code>, and for quite different purposes. I suspect if used <code>panic!</code> for all those things, we would indeed see the same sorts of bugs in sync code -- and this is precisely <strong>why</strong> we chose to encode "recoverable" errors using <code>Result</code> and not <code>panic!</code></p>



<a name="245910266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245910266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245910266">(Jul 14 2021 at 01:40)</a>:</h4>
<p>Just to make sure: the plan is not to remove cancel-by-drop completely, but to add a new way to optionally make futures not-cancelable right? I think it has to be, because making <code>async fn</code> noncancelable would be a breaking change.</p>
<p>In this case then my argument of keeping <code>.await</code> to make cancel points visible still stands. I <em>want</em> to make my futures cancelable, and I want to ensure correct behavior at all cancelation points. </p>
<p>"It's OK to make awaits invisible because all futures will be noncancelable" is not right...</p>



<a name="245911038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245911038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245911038">(Jul 14 2021 at 01:56)</a>:</h4>
<p>I don't think there is any fixed plan yet. There are a couple of ideas, proposals, motivations, goals, interests and concerns. That all still needs to get towards a plan.</p>
<p>And I think one part of the plan would also need to be how to cover backward compatibility and provide a smooth part forward - I certainly also don't believe switching out everything that is available now in one go for something else is the right path to take.</p>
<p>Anyway, I feel like this discussion here diverged a bit from from the initial "assuming we would do away with <code>.await</code>, what other side effects would it have" towards some discussions around other topics like cancellation. Might be good to keep them separate?</p>
<p>I want to talk/write in the near future a bit more about cancellation, including also a bit of background on "what has proven to work for most use-cases" and how a common [graceful] cancellation strategy for both synchronous as well as async Rust code can look like.<br>
But other responsibilities are keeping me busy, so it will likely not be this week.</p>



<a name="245915586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245915586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Chin (eminence) <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245915586">(Jul 14 2021 at 03:32)</a>:</h4>
<p>This is just a tiny bit of anecdotal introspection on my part, but sometimes I like the <code>await</code> suffix.   I find it useful as a flag of sorts, that visually indicates that some "heavy lifting" is happening.   It's true that I sometimes forget to include it, and the compiler yells at me, but I've never been tripped up  by a missing <code>.await</code>.  (It's much more common for me to omit a <code>?</code> operator and gets a fully typed-checked program that is <a href="https://gist.github.com/eminence/4fc0387dc96f3e93edf1c681bc44571d">semantically incorrect</a>)</p>



<a name="245916143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245916143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245916143">(Jul 14 2021 at 03:45)</a>:</h4>
<p>Does anyone have any examples of languages that do implicit await without magic? The "magic" variants (greenlet, fibers, etc) all lead to a lot of "this function might yield, so don't touch anything you care about because it's probably going to break" pseudo-documentation that are explicitly visible to code reviewers if an await keyword is there.</p>
<p>Even Haskell - the language I'd most expect to have done this with its sometimes-excessive use of clever tricks that approach magic, and the fact that almost everything is asynchronous or lazy in some form - uses explicit awaits for effects that cross a thread or task boundary, and often requires you to describe them monadically to further avoid potential ambiguity. Scala, similarly, has a penchant for brevity above all else, and keeps an explicit await despite the PML pattern allowing N-layer implicit casting which could easily invoke an await-like call on Futures.</p>
<p>In other words- is there a reason that other languages that have the option to avoid an explicit <code>await</code> choose not to do so? If it's for type safety, why are languages with even stronger type systems than Rust's hesitant to do so?</p>



<a name="245968646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245968646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245968646">(Jul 14 2021 at 14:36)</a>:</h4>
<p><span class="user-mention" data-user-id="398288">@Zoey</span> Kotlin is the prime example, I believe.</p>



<a name="245968668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245968668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245968668">(Jul 14 2021 at 14:36)</a>:</h4>
<p>And of course Go</p>



<a name="245968679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245968679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245968679">(Jul 14 2021 at 14:37)</a>:</h4>
<p>And pthreads :)</p>



<a name="245970644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/245970644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#245970644">(Jul 14 2021 at 14:52)</a>:</h4>
<p>I have been following only loosely and not sure if I should contribute, but I feel that cpp and python developers would find that rust having a semantically similar model for asynchronous programming, but not using an await keyword very curious. For better or worse, most popular Future/Promise/Coroutine based use an explicit await keyword. Whether or not thats because the design of the language required it to do things in a backwards compat way (i suspect that this is at least tangentially true for python and cpp) is besides the point on what people are used to.<br>
I don't really know anything about js, but they might feel the same.</p>
<p>My own personal opinion is that easily reasoning about the exact locations of yield points, even when async-vision is done and most footguns and perf gotchas are systematically dealt with, is still going to be something people do or want to be able to do, but I have been wrong in the past (like about postfix await haha)</p>



<a name="246028791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246028791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246028791">(Jul 14 2021 at 22:13)</a>:</h4>
<p>From a pull-request reviewer's standpoint, knowing the yield points is only going to get more important as we add concepts like async generators, and not knowing them now is a great way to end up in <code>I don't know what my code is doing without having an IDE to guide me</code> land.</p>



<a name="246040867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246040867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246040867">(Jul 15 2021 at 01:05)</a>:</h4>
<p>Can we put together a list of all the things that explicit <code>await</code> points buy you? I have...</p>
<ul>
<li>More transparent performance characteristics</li>
<li>Much easier to review for cancellation correctness (for implicitly cancellable futures)</li>
<li>Easier to understand "value behind held across an await point" errors</li>
<li>Visibility for severe performance/logic errors like accidentally holding a mutex across an await point, or other "out-of-band synchronization" primitives that interact with concurrency</li>
</ul>



<a name="246040958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246040958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoey <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246040958">(Jul 15 2021 at 01:06)</a>:</h4>
<p>Similarly, is there anything we gain by dropping it, to justify the costs to compilation and intuition complexity? Or is it just because Go?</p>



<a name="246041059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246041059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246041059">(Jul 15 2021 at 01:09)</a>:</h4>
<p>I think that gets covered fairly well in <a href="https://hackmd.io/uAI0q9ZiSwyUkmGQQkyXXg?view#await-syntax">niko's doc</a></p>



<a name="246041060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246041060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246041060">(Jul 15 2021 at 01:09)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> Easier to pass around a future without accidentally awaiting it, which means easier use of future combinators and similar.</p>



<a name="246045404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246045404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246045404">(Jul 15 2021 at 02:30)</a>:</h4>
<blockquote>
<p>More transparent performance characteristics</p>
</blockquote>
<p>Why is that? I can see some reasoning around "we are sure it will not block the runtime/thread, because it has an <code>.await</code> behind it". Anything else?</p>



<a name="246045581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246045581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246045581">(Jul 15 2021 at 02:34)</a>:</h4>
<blockquote>
<p>@tmandry Easier to pass around a future without accidentally awaiting it, which means easier use of future combinators and similar.</p>
</blockquote>
<p>And easier to create a stack overflow ;) <br>
Just kidding. I feel like this is in line with <span class="user-mention" data-user-id="116883">@tmandry</span> 's comment of</p>
<blockquote>
<p>Much easier to review for cancellation correctness (for implicitly cancellable futures)</p>
</blockquote>
<p>which applies more to implicitly cancellable futures? I can't think of too many reasons why you want to move the other version around too much - in my use of Go or Kotlin code I didn't feel like the need to have raw access to the tasks stack or whatever is equivalent to a <code>Future</code> there.</p>



<a name="246049822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246049822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246049822">(Jul 15 2021 at 04:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/meeting.202021-07-09/near/245474032">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="204219">Matthias247</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/meeting.202021-07-09/near/245473817">said</a>:</p>
<blockquote>
<p>Would be great if one could write <code>async fn myfunc(callback: impl AsyncFnOnce)</code> and get exactly the same semantics as with synchronous functions. It isn't really that easy with passing the current version of <code>Future</code> due to lifetime differences.</p>
</blockquote>
<p>I don't quite understand what you mean by this, can you elaborate a bit?</p>
</blockquote>
<p>Moving the answer over into this thread, since I think it fits better. <br>
Let's look into this gist, which makes use callback functions in the same way in both the sync as well as async world: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=e46acb168f3d07ce73b09dfbfce8425a">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=e46acb168f3d07ce73b09dfbfce8425a</a></p>
<p>While the synchronous version is straightforward, the async one compiles with a hard-to-understand lifetime issue, where also the fix is non-obvious. I run into those kind of things in various places in the async world, and usually end up with either restructuring or boxing everything.</p>
<p>I was wondering if implicit await could allow to get the async experience closer to the synchronous one - exactly because people can't move futures around manually anymore and there might be more guarantees on when the produced future might be used. </p>
<p>Obviously I'm totally not sure about it, and I guess it would only be if there is additional requirements on the <code>unsafe</code> poll method.</p>
<p>But getting these things to work easier would be a much stronger motivator for me to drop <code>.await</code> than the pure syntactic motivations.</p>



<a name="246061213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/246061213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kestrer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#246061213">(Jul 15 2021 at 07:40)</a>:</h4>
<p>Implicit await wouldn't help at all in the playground you linked. The problem there is the lack of higher kinded types, which could be implemented both with or without implicit await. Even giving the guarantee that the future is immediately awaited wouldn't help much I don't think, we just need to have the compiler support async closures and then it will all be fine.</p>



<a name="248540023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/248540023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonathan de Jong <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#248540023">(Aug 05 2021 at 21:33)</a>:</h4>
<p>I’m sure this sentiment has been repeated been time and time again, in much more detail than this, but my opinion is to keep the keyword, as it is (imo) the perfect trade-off between explicitness and DRY, here</p>
<p>Knowing where a yield point is, and what exactly is being yielded into what where, is very important if you want to explicitly control your asynchronous control flow in such a function, I can imagine much frustration when <em>not</em> being in control of this, when a call simply yields right then and there, while there much value in passing around the actual future that should be awaited, I.e. to pass into FuturesUnordered, or to mess around with it, reordering when and where yielding occurs, to satisfy the borrow checker</p>



<a name="248540355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/248540355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonathan de Jong <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#248540355">(Aug 05 2021 at 21:36)</a>:</h4>
<p>In short, I’d rather know when my program is yielding, than having to guess and “tamper” to get it to do what I want</p>



<a name="248575120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Dropping%20%60.await%60-%20what%20else%20could%20or%20would%20change/near/248575120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kestrer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Dropping.20.60.2Eawait.60-.20what.20else.20could.20or.20would.20change.html#248575120">(Aug 06 2021 at 06:13)</a>:</h4>
<p><span class="user-mention" data-user-id="300259">@Jonathan de Jong</span> What about <code>AsyncDrop</code>? Take this code, for example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">stream</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">TlsStream</span>::<span class="n">connect</span><span class="p">(</span><span class="n">addr</span><span class="p">).</span><span class="k">await</span><span class="o">?</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">stream</span><span class="p">.</span><span class="n">write_all</span><span class="p">(</span><span class="n">data</span><span class="p">).</span><span class="k">await</span><span class="o">?</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="c1">// stream is replaced, the old stream is dropped, a yield point is inserted</span>
<span class="w">    </span><span class="n">stream</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">TlsStream</span>::<span class="n">connect</span><span class="p">(</span><span class="n">another_addr</span><span class="p">).</span><span class="k">await</span><span class="o">?</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">stream</span><span class="p">.</span><span class="n">write_all</span><span class="p">(</span><span class="n">more_data</span><span class="p">).</span><span class="k">await</span><span class="o">?</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="c1">// another stream is created then dropped, and a yield point is inserted</span>
<span class="w">    </span><span class="n">TlsStream</span>::<span class="n">connect</span><span class="p">(</span><span class="n">third_addr</span><span class="p">).</span><span class="k">await</span><span class="o">?</span><span class="p">.</span><span class="n">write_all</span><span class="p">(</span><span class="n">even_more_data</span><span class="p">).</span><span class="k">await</span><span class="o">?</span><span class="p">;</span><span class="w"></span>


<span class="w">    </span><span class="c1">// stream is implicitly dropped, a yield point is inserted</span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>The above code has three yield points where there was no explicit await. To be honest I'm not really sure what to do here, but I'm leaning towards having those yield points not also be cancellation points.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>